home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / PInterfaces / UViewCoords.p < prev   
Encoding:
Text File  |  1990-10-25  |  3.8 KB  |  122 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2. { UViewCoords.p }
  3. { Copyright © 1987-1990 by Apple Computer, Inc.  All rights reserved. }
  4.  
  5. {$IFC UNDEFINED UsingIncludes}
  6. {$SETC UsingIncludes := FALSE}
  7. {$ENDC}
  8.  
  9. {$IFC NOT UsingIncludes}
  10. UNIT UViewCoords;
  11.  
  12.     INTERFACE
  13.         {$ENDC}
  14.  
  15.         {$IFC UNDEFINED UsingUViewCoords}
  16.         {$SETC __UViewCoords__ := FALSE}
  17.         {$ENDC}
  18.  
  19.         {$IFC NOT __UViewCoords__}
  20.         {$SETC __UViewCoords__ := TRUE}
  21.  
  22.         { • Auto-Include the requirements for this unit's interface. }
  23.         {$SETC UViewCoordsIncludes := UsingIncludes}
  24.         {$SETC UsingIncludes := TRUE}
  25.         {$I+}
  26.         {$IFC UNDEFINED __UMacAppUtilities__} {$I UMacAppUtilities.p} {$ENDC}
  27.         {$SETC UsingIncludes := UViewCoordsIncludes}
  28.  
  29.         CONST
  30.             kMaxCoord            = 30000;                { largest possible QuickDraw view coordinate
  31.                                                          (QuickDraw maximum minus slop for size of
  32.                                                          screen) }
  33.  
  34.             { Calculations with VPoints }
  35.  
  36.         PROCEDURE PtToVPt(thePt: Point;
  37.                           VAR theVPt: VPoint);
  38.         { Convert a QD Point to a VPoint. }
  39.  
  40.         FUNCTION VPtToPt(theVPt: VPoint): Point;
  41.         { Convert a VPoint to a QD Point. }
  42.  
  43.         PROCEDURE AddVPt(srcVPt: VPoint;
  44.                          VAR dstVPt: VPoint);
  45.         { Adds the coordinates of 'srcVPt' to the coordinates of 'dstVPt' returning result in
  46.         'dstVPt'. }
  47.  
  48.         PROCEDURE SubVPt(srcVPt: VPoint;
  49.                          VAR dstVPt: VPoint);
  50.         { Subtracts the coordinates of 'srcVPt' from the coordinates of 'dstVPt' returning result in
  51.         'dstVPt'. }
  52.  
  53.         PROCEDURE SetVPt(VAR vPt: VPoint;
  54.                          h, v: VCoordinate);
  55.         { Assigns the two given coordinates to 'vPt'. }
  56.  
  57.         FUNCTION EqualVPt(pt1, pt2: VPoint): BOOLEAN;
  58.         { Compares the two VPoints returning TRUE if they are equal and FALSE if not. }
  59.  
  60.         { Calculations with VRects }
  61.  
  62.         PROCEDURE RectToVRect(theRect: Rect;
  63.                               VAR theVRect: VRect);
  64.         { Converts a QD Rect to a VRect. }
  65.  
  66.         PROCEDURE VRectToRect(theVRect: VRect;
  67.                               VAR theRect: Rect);
  68.         { Converts a VRect to a QD Rect. }
  69.  
  70.         PROCEDURE SetVRect(VAR r: VRect;
  71.                            left, top, right, bottom: VCoordinate);
  72.         { Sets the boundary coordinates of the VRect 'r' . }
  73.  
  74.         PROCEDURE OffsetVRect(VAR r: VRect;
  75.                               dh, dv: VCoordinate);
  76.         { Moves the given VRect by adding 'dh' to each horizontal and 'dv' to each vertical
  77.         coordinate. Postive values cause the movement to be to the right and down, while negative
  78.         are the opposite. }
  79.  
  80.         PROCEDURE InsetVRect(VAR r: VRect;
  81.                              dh, dv: VCoordinate);
  82.         { Shrinks or expands the given VRect.The left and right sides are moved in by 'dh', the top
  83.         and bottom by 'dv'. If the values are negative the movement is outward. }
  84.  
  85.         FUNCTION PtInVRect(pt: VPoint;
  86.                            r: VRect): BOOLEAN;
  87.         { Determines whether the pixel below and to the right of the given coordinate is enclosed by
  88.         the specified VRect, returns TRUE if so or FALSE if not. }
  89.  
  90.         FUNCTION SectVRect(src1, src2: VRect;
  91.                            VAR dstRect: VRect): BOOLEAN;
  92.         { Calculates the VRect that is the intersection of the two given VRects, returns TRUE if they
  93.         intersect and FALSE if not. }
  94.  
  95.         FUNCTION EmptyVRect(r: VRect): BOOLEAN;
  96.         { Returns TRUE if the given VRect is an empty VRect, FALSE if not. }
  97.  
  98.         FUNCTION EqualVRect(rectA, rectB: VRect): BOOLEAN;
  99.         { Compares the two given VRects and returns TRUE if they are equal FALSE if not. }
  100.  
  101.         FUNCTION LengthVRect(r: VRect;
  102.                              vhs: VHSelect): VCoordinate;
  103.         { Returns the length of the given VRect in the direction determined by 'vhs'. }
  104.  
  105.         PROCEDURE PinVRect(r: VRect;
  106.                            VAR pt: VPoint);
  107.         { Pins the given VPoint to the given VRect. }
  108.  
  109.         PROCEDURE UnionVRect(src1, src2: VRect;
  110.                              VAR dstRect: VRect);
  111.         { Calculates the smallest VRect that encloses both the given VRects, returns the result in
  112.         'dstRect'. }
  113.  
  114.         PROCEDURE Pt2VRect(topLeft, botRight: VPoint;
  115.                            VAR dstRect: VRect);
  116.         { Returns the smallest VRect that  encloses to given VPoints. }
  117.         {$ENDC}
  118.  
  119.         {$IFC NOT UsingIncludes}
  120. END.
  121. {$ENDC}
  122.